package course.p7_binaryTree.s3_BSTree;

import course.p7_binaryTree.Node;
import org.junit.Test;

/**
 * 二叉搜索树的存储结构是具有排序属性的
 */
public class BSTreeTest {


    @Test
    public void insertTest() {
        BSTree bsTree = new BSTree();
        Node root = bsTree.insert(null,5);
        for(int i=0;i<10;i++) {
            bsTree.insert(root,i);
        }
        bsTree.middleTraverse(root);
    }

    @Test
    public void deleteTest() {
        BSTree bsTree = new BSTree();
        Node root = bsTree.insert(null,5);
        for(int i=0;i<10;i++) {
            bsTree.insert(root,i);
        }
        bsTree.middleTraverse(root);
        System.out.println();
        for(int i=3;i<8;i++) {
            bsTree.delete(root,i);
            bsTree.middleTraverse(root);
            System.out.println();
        }
    }

}
